Ext.define('Admin.view.overtimehistory.OvertimeHistoryViewController', {
    extend: 'Ext.app.ViewController',
    alias: 'controller.overtimeHistoryViewController',

    

    OvertimeGridWindowClose: function(bt) {
        var win = bt.up('window');
        if (win) {
            win.close();
        }
    },

    

    overtimeHistoryGridPanelSearch:function(){
        var serchApplicationTime    =  Ext.util.Format.date(this.lookupReference('overtimeGridSerchByapplicationTime').getValue(),'Y/m/d H:i:s');
        var serchDepartment         =  this.lookupReference('overtimeGridSerchBydepartment').getValue();
        var serchName               =  this.lookupReference('overtimeGridSerchByname').getValue();
        var store = Ext.getCmp('overtimeHistoryGrid').getStore();
        
        if (serchApplicationTime!='') {
            Ext.apply(store.proxy.extraParams,{
                applicationTime:serchApplicationTime
            });
        }else{
            if (store.getProxy().extraParams.applicationTime!=null) {
                delete store.getProxy().extraParams.applicationTime;
            }
        }
        if (serchDepartment!='') {
            Ext.apply(store.proxy.extraParams,{
                department:serchDepartment
            });
        }
        if (serchName!=null) {
            Ext.apply(store.proxy.extraParams,{
                name:serchName
            });
        }

        store.load({
            start: 0,
            limit: 25,
            page: 1
        })
    },

    overtimeHistoryGridPanelclear:function(){
        this.lookupReference('overtimeGridSerchByapplicationTime').setValue('');
        this.lookupReference('overtimeGridSerchBydepartment').setValue('');
        this.lookupReference('overtimeGridSerchByname').setValue('');
    },

    overtimeHistoryGridExport:function(){
        var serchApplicationTime    =  Ext.util.Format.date(this.lookupReference('overtimeGridSerchByapplicationTime').getValue(),'Y/m/d H:i:s');
        var serchDepartment         =  this.lookupReference('overtimeGridSerchBydepartment').getValue();
        var serchName               =  this.lookupReference('overtimeGridSerchByname').getValue();
        var url = '';

        if (serchApplicationTime!=''&&serchApplicationTime!=null) {
            url+=('&applicationTime='+serchApplicationTime);
        }
        if (serchDepartment!=''&&serchDepartment!=null) {
            url+=('&department='+serchDepartment);
        }
        if (serchName!=''&&serchName!=null) {
            url+=('&name='+serchName);
        }

        window.open('overtime/export?state=已完成'+url, '导出Excel');
    }
});